package machinery.decorator;

import machinery.Machinery;
import java.util.Map;

/**
 * 精准导航系统装饰器：给农机添加高精度GPS导航功能
 */
public class PrecisionGuidanceDecorator extends MachineryDecorator {
    
    public PrecisionGuidanceDecorator(Machinery decoratedMachinery) {
        super(decoratedMachinery);
        System.out.println("为" + decoratedMachinery.getName() + "安装精准导航系统");
    }
    
    @Override
    protected void additionalUpdate(Map<String, Object> environmentData) {
        System.out.println(getName() + " 精准导航系统分析环境数据...");
        
        if (environmentData.containsKey("windSpeed")) {
            Integer windSpeed = (Integer) environmentData.get("windSpeed");
            if (windSpeed > 15) {
                System.out.println(getName() + " 精准导航系统: 检测到强风(" + windSpeed + "m/s)，自动调整路线补偿风偏");
            }
        }
    }
    
    @Override
    public String getName() {
        return decoratedMachinery.getName() + "[精准导航]";
    }
    
    // 额外方法：路线优化
    public void optimizeRoute() {
        System.out.println(getName() + " 使用精准导航系统优化作业路线");
        System.out.println("  - 使用RTK精准定位");
        System.out.println("  - 误差控制在±2cm");
        System.out.println("  - 避免重复作业");
    }
} 